// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   DefaultDataMode.java

package org.quickserver.util.xmlreader;

import java.io.Serializable;
import org.quickserver.net.server.DataMode;
import org.quickserver.net.server.DataType;

public class DefaultDataMode
    implements Serializable
{

    public DefaultDataMode()
    {
        defaultDataModeIN = DataMode.STRING;
        defaultDataModeOUT = DataMode.STRING;
    }

    public void setDataModeIn(String dataMode)
    {
        if(dataMode.toUpperCase().equals("STRING"))
            defaultDataModeIN = DataMode.STRING;
        else
        if(dataMode.toUpperCase().equals("BYTE"))
            defaultDataModeIN = DataMode.BYTE;
        else
        if(dataMode.toUpperCase().equals("OBJECT"))
            defaultDataModeIN = DataMode.OBJECT;
        else
        if(dataMode.toUpperCase().equals("BINARY"))
            defaultDataModeIN = DataMode.BINARY;
    }

    public String getDataModeIn()
    {
        return defaultDataModeIN.toString();
    }

    public void setDataModeOut(String dataMode)
    {
        if(dataMode.toUpperCase().equals("STRING"))
            defaultDataModeOUT = DataMode.STRING;
        else
        if(dataMode.toUpperCase().equals("BYTE"))
            defaultDataModeOUT = DataMode.BYTE;
        else
        if(dataMode.toUpperCase().equals("OBJECT"))
            defaultDataModeOUT = DataMode.OBJECT;
        else
        if(dataMode.toUpperCase().equals("BINARY"))
            defaultDataModeOUT = DataMode.BINARY;
    }

    public String getDataModeOut()
    {
        return defaultDataModeOUT.toString();
    }

    public void setDataMode(DataMode dataMode, DataType dataType)
    {
        if(dataType == DataType.IN)
            defaultDataModeIN = dataMode;
        if(dataType == DataType.OUT)
            defaultDataModeOUT = dataMode;
    }

    public DataMode getDataMode(DataType dataType)
    {
        if(dataType == DataType.IN)
            return defaultDataModeIN;
        if(dataType == DataType.OUT)
            return defaultDataModeOUT;
        else
            throw new IllegalArgumentException((new StringBuilder("Unknown DataType: ")).append(dataType).toString());
    }

    public String toXML(String pad)
    {
        if(pad == null)
            pad = "";
        StringBuilder sb = new StringBuilder();
        sb.append(pad).append("<default-data-mode>\n");
        sb.append(pad).append("\t<data-type-in>").append(getDataModeIn()).append("</data-type-in>\n");
        sb.append(pad).append("\t<data-type-out>").append(getDataModeOut()).append("</data-type-out>\n");
        sb.append(pad).append("</default-data-mode>\n");
        return sb.toString();
    }

    private DataMode defaultDataModeIN;
    private DataMode defaultDataModeOUT;
}
